#define _CRT_SECURE_NO_WARNINGS 1

//https://leetcode.cn/problems/teemo-attacking/

class Solution {
public:
    int findPoisonedDuration(vector<int>& timeSeries, int duration) {
        int n = timeSeries.size();
        int ret = 0;
        for (int i = 0; i < n - 1; i++)
        {
            if ((timeSeries[i + 1] - timeSeries[i]) >= duration) ret += duration;
            else ret += timeSeries[i + 1] - timeSeries[i];
        }
        ret += duration;
        return ret;
    }
};